package com.ryskoo.framework.core.bean;

import java.io.Serializable;

/**
 * 分页对象，将列表分页进行封装，统一处理
 * 
 * @author ruiyun
 *
 */
public class Pager implements Serializable {

	private int pageShow = 10;

	private int nowPage = 1;

	private int totalNum = 0;

	private int totalPage = 1;

	public Pager() {

    }

    public Pager(int pageShow, int nowPage, int totalNum) {
	    this.pageShow = pageShow;
	    this.nowPage = nowPage;
	    this.totalNum = totalNum;
    }

	public int getStartNum() {
		return (getNowPage() - 1) * this.pageShow;
	}

	public int getPageShow() {
		return this.pageShow;
	}

	public void setPageShow(int pageShow) {
		this.pageShow = pageShow;
	}

	public int getNowPage() {
		if (this.nowPage <= 0) {
			this.nowPage = 1;
		}
		if (this.nowPage > getTotalPage()) {
			this.nowPage = getTotalPage();
		}
		return this.nowPage;
	}

	public void setNowPage(int nowPage) {
		this.nowPage = nowPage;
	}

	public int getTotalNum() {
		return this.totalNum;
	}

	public void setTotalNum(int totalNum) {
		this.totalNum = totalNum;
	}

	public int getTotalPage() {
		if (this.totalNum > 0) {
			return (int) Math.ceil(this.totalNum * 1.0D / this.pageShow);
		}
		return this.totalPage;
	}
}
